package com.lagou.server;

import com.lagou.demo.HelloServiceImpl;
import com.lagou.demo.IHelloService;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

public class RMIServer {

    public static void main(String[] args) throws RemoteException, AlreadyBoundException, MalformedURLException {


        //创建HelloService的实例
        IHelloService service = new HelloServiceImpl();


        //获取注册表
        LocateRegistry.createRegistry(8888);


        //对象的绑定
        //bind方法参数：rmi：ip地址：端口/服务名
        //参数2,：绑定的对象
        Naming.bind("//127.0.0.1:8888/rmiserver",service);
    }

}
